package com.autumn.config.api.dto.output;

import com.autumn.config.api.consts.ConfigureConsts.ConnectionTypeConsts;
import com.autumn.util.AutumnContextUtils;

import java.util.Map;

/**
 * 连接配置输出
 * 
 * @author 老码农
 *         <p>
 *         Description
 *         </p>
 * @date 2017-12-31 00:56:12
 */
public class ConnectionConfigureOutput extends ConfigureBaseOutput {

	/**
	 * 
	 */
	private static final long serialVersionUID = -279704146177491192L;
	private String name;
	private Integer connectionType;
	private String propertyContent;

	/**
	 * 
	 */
	public ConnectionConfigureOutput() {

	}

	/**
	 * 获取名称
	 * 
	 * @return
	 */
	public String getName() {
		return name;
	}

	/**
	 * 设置名称
	 * 
	 * @param name
	 *            名称
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * 获取连接类型
	 * 
	 * @return
	 */
	public Integer getConnectionType() {
		return connectionType;
	}

	/**
	 * 设置连接类型
	 * 
	 * @param connectionType
	 *            连接类型
	 */
	public void setConnectionType(Integer connectionType) {
		this.connectionType = connectionType;
	}

	/**
	 * 获取属性内容
	 * 
	 * @return
	 */
	public String getPropertyContent() {
		return propertyContent;
	}

	/**
	 * 设置属性内容
	 * 
	 * @param propertyContent
	 *            属性内容
	 */
	public void setPropertyContent(String propertyContent) {
		this.propertyContent = propertyContent;
		if (this.propertys != null) {
			this.propertys = null;
		}
	}

	/**
	 * 获取连接类型名称
	 * 
	 * @return
	 */
	public String getConnectionTypeName() {
		return ConnectionTypeConsts.getName(this.getConnectionType());
	}

	private Map<String, Object> propertys = null;

	/**
	 * 获取属性 Map
	 * 
	 * @return
	 */
	public Map<String, Object> getPropertys() {
		if (this.propertys == null) {
			this.propertys = AutumnContextUtils.parseProperties(this.getPropertyContent(), false);
		}
		return this.propertys;
	}
}
